Skip to content

Fix rate limiting on scan - #6

Merged
stefan-as merged 7 commits into
masterfrom
fix/rate_limiting_on_scan
Oct 1, 2020
Merged

Fix rate limiting on scan#6
stefan-as merged 7 commits into
masterfrom
fix/rate_limiting_on_scan

Conversation

@stefan-as

Copy link
Copy Markdown
Contributor

Der Check ruft zweimal die QuayIO-API auf. Der Schutz gegen Rate-Limiting war aber nur an einem Aufruf implementiert. Ich habe den Moment genutzt, um die API-Calls zu generalisieren und in eine eigene Klasse zu kapseln.

@stefan-as
stefan-as requested a review from bennibu September 28, 2020 13:31

@bennibu bennibu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moin Stefan, du hast ja einiges umgebaut hier. Als zentralen Unterschied zu vorher sehe ich, dass der scanner bei einem 520 oder nach 5 Versuchen austeigt. Vorher hat er bei einem 520 es trotzdem noch 5 mal versucht. Inwieweit soll das das Problem lösen?

@stefan-as

Copy link
Copy Markdown
Contributor Author

@bennibu an der Stelle hab ich eigentlich nur die Logik umgedreht, weil sich das besser im Code gemacht hat (bisher: bei 520 und weniger als 5 weitermachen; jetzt: bei nicht 520 oder mehr als 5 aussteigen).

Der relevante Teil ist, dass es zwei API-Calls gibt und bisher nur der erste API-Call abgesichert war. Mit dem neuen Code sind beide API-Calls abgesichert:

RestClient.get("https://quay.io/api/v1/repository/#{repo}/image/#{raw_image['id']}/security?vulnerabilities=true",
authorization: "Bearer #{quayio_token}", accept: :json)

@bennibu

bennibu commented Sep 29, 2020

Copy link
Copy Markdown
Contributor

@stefan-as Kompliziert, aber ich verstehe jetzt. Ist auf jeden Fall deutlich lesbarer als vorher. Danke.

@jonathanschlue-as jonathanschlue-as left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VIelen Dank! Habe wie folgt gereviewed:

Die Code-Vorschläge sind als Anmerkungen, nicht als Wünsche gemeint.
Lass uns über die konzeptionellen Fragen gerne nochmal sprechen.
Im folgenden noch eine Sache, die mir insgesamt mit dem Repo aufgefallen ist:


Review zu Code außerhalb der Änderungen diesen PRs

Anmerkung: Imho ist es Convention im "Root"-File eines Gems alle Dateien in (Sub-)Modulen des Gems (quayio/scanner/image, quayio/scanner/repository, ...) einzusammeln, und in den einzelnen Files der Module nur noch externe Dependencies (docker, rest-client, ...) zu requiren. Z.B.:

# lib/quayio/scanner.rb

require 'quayio/scanner/check'
require 'quayio/scanner/image'
require 'quayio/scanner/repository'
require 'quayio/scanner/version'

module Quayio
  module Scanner
  end
end

Siehe

require 'quayio/scanner/version'
require 'quayio/scanner/check'
module Quayio
module Scanner
end
end

Ein Beleg: https://ryanlue.com/posts/2017-03-03-how-to-structure-a-library#rule-3-one-file-to-rule-them-all

Comment thread lib/quayio/scanner/image.rb Outdated
Comment thread lib/quayio/scanner/image.rb
Comment thread lib/quayio/scanner/image.rb Outdated
Comment thread lib/quayio/scanner/repository.rb Outdated
Comment thread lib/quayio/scanner/repository.rb Outdated
Comment thread lib/quayio/scanner/repository.rb

@jonathanschlue-as jonathanschlue-as left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noch ein paar Ruby-Dinge

Comment thread lib/quayio/scanner/image.rb Outdated
Comment thread lib/quayio/scanner/image.rb Outdated
Comment thread lib/quayio/scanner/image.rb Outdated
Comment thread lib/quayio/scanner/repository.rb
@stefan-as
stefan-as merged commit 167498a into master Oct 1, 2020
@jonathanschlue-as
jonathanschlue-as deleted the fix/rate_limiting_on_scan branch May 23, 2022 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants